package com.wyh.strategy.g3impl;

import com.wyh.domain.po.g3po.G3Contractitem;
import com.wyh.strategy.g3strategy.CalculationBillAmount;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class CalculationFee {
    //注入策略类
    @Autowired
    private List<CalculationBillAmount> list;
    Map<Integer, CalculationBillAmount> map = new HashMap<>();
    @PostConstruct
    public void init() {
        list.forEach(e -> {
            map.put(e.getClass().getAnnotation(Order.class).value(), e);
        });
    }

    public Double calculationBillAmount(G3Contractitem g3Contractitem) {
        return map.get(g3Contractitem.getMethod()).calculationBillAmount(g3Contractitem);
    }
}
